<?php

/*
 * Built by :
 * Andi Kurniawan (fandikurniawan89@gmail.com) at system analis
 */

class Main extends CI_Controller {

    function __construct() {
        parent::__construct();
    }

    function index() {
        $this->load->view('theme/login');
    }

    function login() {
        $input = array(
            'username' => $this->input->post('username'),
            'password' => $this->encrypt->sha1($this->input->post('password'))
        );
        if ($this->mmr->login($input)) {
            $data = $this->mmr->login($input);
            $pri = $data->pri;
        } else {
            redirect();
        }
        if ($pri == 1) {
            $set = array(
                'username' => $this->input->post('username'),
                'login' => TRUE,
                'pri' => 1,
            );
            $this->session->set_userdata($set);
            redirect('admin');
        } elseif ($pri == 2) {
            $set = array(
                'username' => $this->input->post('username'),
                'login' => TRUE,
                'pri' => 2,
            );
            $this->session->set_userdata($set);
            redirect('dosen');
        } elseif ($pri == 3) {
            $set = array(
                'username' => $this->input->post('username'),
                'login' => TRUE,
                'pri' => 3,
            );
            $this->session->set_userdata($set);
            redirect('mahasiswa');
        } else {
            redirect();
        }
    }

    function logout() {
        $this->session->sess_destroy();
        redirect();
    }

}

?>
